
import 'dart:convert';

import 'package:flutter_trip/model/travel_tab_model.dart';
import 'package:http/http.dart' as http;

class TravelTabDao{
  static Future<TravelTabModel> fetch() async{
    var url = Uri.parse('http://www.devio.org/io/flutter_app/json/travel_page.json');
    final response =await http.get(url);
    if(response.statusCode == 200){
      Utf8Decoder utf8decoder = Utf8Decoder();//修复中文乱码问题
      var result = json.decode(utf8decoder.convert(response.bodyBytes));
      //只有当前输入的内容和服务端返回的内容一致时才渲染
      TravelTabModel model= TravelTabModel.fromJson(result);
      return model;
    }else{
      throw Exception("加载HomeJson失败");

    }
  }
}